<?php 
$id = $_GET['id'];
if(!is_numeric($id)){
	header('Location: index.php');
}
require('includes/eshop_fns.php');

$conn = db_connect();
$sql = 'SELECT * FROM `product` WHERE `product_id` = :id AND `product_status` = 1';
$stmt = $conn -> prepare($sql);
$stmt -> bindParam(':id',$id);
$stmt -> execute();
$vo = $stmt -> fetch();

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $vo['product_name']?></title>
</head>

<body>
<?php 
if($stmt -> rowCount() == 0){
	echo '<table align="center"><tr><td>该产品不存在! <a href="index.php">[返回首页]</a></td></tr></table>';
}else{
?>
产品展示
<?php 
$sql2 = 'SELECT `product_type_name` FROM `product_type` WHERE `product_type_id` = :type_id';
$stmt2 = $conn -> prepare($sql2);
$stmt2 -> bindParam(':type_id',$vo['product_type_id']);
$stmt2 -> execute();
$vo2 = $stmt2 -> fetchColumn();
?>
<table width="381" border="1" align="center">
<form name="buyform" method="post" action="cart.php?act=add">
<input name="id" value="<?php echo $id;?>" type="hidden" />
  <tr>
    <td width="97">产品名称</td>
    <th width="268"><?php echo $vo['product_name'];?></th>
  </tr>
  <tr>
    <td>所属类别</td>
    <td><?php echo $vo2; ?></td>
  </tr>
  <tr>
    <td>价格</td>
    <td><?php echo $vo['product_price'];?></td>
  </tr>
  <tr>
    <td>描述</td>
    <td><?php echo $vo['product_content'];?></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><input name="submit" type="submit" value="加入购物车"/></td>
  </tr>
  </form>
</table>
<?php 
}
?>
</body>
</html>
